<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>Document</title>
	</head>

	<body>
		<div id="app">
			<cpn></cpn>
			<!-- 父组件为了获取子组件中pLanguages -->
			<cpn>
				<!-- slot-scope插槽作用域 最新已修改成v-slot-->
				<template v-slot="slot">
					<!-- <span v-for="item in slot.data">{{item}}-</span> -->
					<span>{{slot.data.join('-')}}</span>
				</template>
			</cpn>
			<cpn>
				<template slot-scope="slot">
					<!-- <span v-for="item in slot.data">{{item}}*</span> -->
					<span>{{slot.data.join('*')}}</span>
				</template>
			</cpn>
		</div>

		<template id="cpn">
			<div>
				<slot :data="pLanguages">
					<ul>
						<li v-for="item in pLanguages">{{item}}</li>
					</ul>
				</slot>
			</div>
		</template>
		<script src="../lib/vue.js"></script>
		<script>
			let vm = new Vue({
				el: "#app",
				data: { message: "hello" },
				components: {
					cpn: {
						template: "#cpn",
						data() {
							return {
								pLanguages: [
									"Javascript",
									"c++",
									"Java",
									"Go",
									"Swift",
									"Python"
								]
							};
						}
					}
				}
			});
		</script>
	</body>
</html>
